<html lang="java">
<head>
    <title>123</title>
    <script type="text/javascript">
        window.onload = function () {
            //下拉框选中
            const mySelect = document.getElementById("mySelect");
            const opts = mySelect.options;
            for (let i = 0; i < opts.length; i++) {
                if (opts[i].value == ${dId!'0'}) {
                    opts[i].selected = true;
                }
            }

            //全选
            const alleIds = document.getElementById("alleIds");
            const eIds = document.getElementsByName("eIds");
            alleIds.onchange = function () {
                for (let i = 0; i < eIds.length; i++) {
                    if (!(eIds[i].disabled))
                        eIds[i].checked = alleIds.checked;
                }
            }
        };

        //定义一个方法清空，查询的条件
        function toreset() {
            var  selectname = document.getElementById("selectname");
            var  mySelect = document.getElementById("mySelect");
              selectname.value = "";
          var op =  mySelect.options;
          op[0].selected = true;
        }

        //定义一个方法，查看是否有选项选中
        function tosubmit() {
            var eIds = document.getElementsByName("eIds");
            var arr = [];
            for (let i = 0; i < eIds.length; i++) {
                if (eIds[i].checked) {
                    arr.push(1);
                }
            }
            if (arr.length > 0) {
                document.forms[1].submit();
            } else {
                alert("没有可以选中的选项");
            }
        }

        //批量删除
        function todelete() {
            if (confirm("确定删除？")) {
                //设置隐藏域的值
                document.getElementById("method").value = "delete";
                tosubmit();
            }
        }

        //导出
        function todaochu() {
            if (confirm("确定导出？")) {
                document.getElementById("method").value = "daochu";
                //提交表单
                /*   document.forms[1].submit();*/
                tosubmit();
            }
        }
    </script>
    <style type="text/css">
        body {

            background-size: 100% 100%;
            height: 100%;
            width: 100%;
            text-align: center;
            margin-top: 50px;
            margin-left: auto;
        }

        table {
            text-align: center;
            margin: auto;
            text-decoration-color: #E3E6EB;
        }

        h1 {
            font-size: 35px;
            color: #5d5a8b;
        }
    </style>
</head>
<body style="background-image:url('/static/img/31.jpg');">
<h1>员工管理</h1>
<#--        超级管理员-->
<form action="/record/selectemployee" method="post">
    <table cellpadding="8" cellspacing="1">
        <tr>
            <td>姓名：</td>
            <td><input type="text" value="${eName?if_exists}" name="eName" id="selectname"/></td>
            <td>所属部门：</td>
            <td>
                <select name="dId" id="mySelect">
                    <option value="0">全部</option>
                    <#list  departments as department>
                        <option value="${department.dId?if_exists}">${department.dName?if_exists}</option>
                    </#list>
                </select>
            </td>
            <td rowspan="2"><input type="submit" value="查询">&nbsp;<input type="button" value="清除" onclick="toreset()"></td>
        </tr>
    </table>
</form>
<#if  emppage.list?size == 0>
    <h1 style="text-align: center ;color: #1c94c4" >没有您查询的数据！<a  style="color: #1c94c4" href="/record/selectemployee">返回</a></h1>
    <#else >
<div class="div_head" style="margin-left: 25% ; margin-top: auto">
    <#if   currentUser.role.rLevel  !=   1  >
        <span>
                    <span onclick="todaochu()" style="color: blue; cursor: pointer">【导出数据】</span>
                   <span>  <a style="text-decoration: none;" href="/record/insertemployee.html">【添加】</a></span>
                    <span onclick="todelete()" style="color: blue; cursor: pointer">【删除】</span>
            </span>
    </#if>
</div>
<br/>
<form action="/record/deleteanddaochuemployee" method="post">
    <input type="hidden" id="method" name="method">
    <table cellpadding="4" cellspacing="0" border="1">
        <tr>
            <td width="30px;"><input type="checkbox" id="alleIds"/></td>
            <td>序号</td>
            <td>员工账号</td>
            <td>姓名</td>
            <td>手机号</td>
            <td>所属部门</td>
            <td>职位</td>
            <td>最后登录</td>
            <td>是否启动</td>
            <td>操作</td>
        </tr>
        <#list  emppage.list as empolyee>
            <tr>
                    <#if  empolyee.role.rLevel <  currentUser.role.rLevel >
                        <td><input type="checkbox" name="eIds" value="${empolyee.eId!''}"/></td>
                    <#else >
                        <td></td>
                    </#if>
                <td>${empolyee_index+1!''}</td>
                <td>${empolyee.loginName!''}</td>
                <td>${empolyee.eName!''}</td>
                <td>${empolyee.eTel!''}</td>
                <td>${empolyee.department.dName!''}</td>
                <td>${empolyee.role.rName!''}</td>
                <td>
<#--                    <#if empolyee.eEndTime??>-->
                        ${empolyee.eEndTime!''}
<#--                    </#if>-->
                </td>
                <#if  empolyee.eState == 1>
                    <td>启动</td>
                    <td>

                        <#if  currentUser.role.rLevel  == 1>
                            <#if  empolyee.eId ==  currentUser.eId >
                                <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                                <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                            </#if>
                        </#if>

                        <#if  currentUser.role.rLevel  == 2>
                            <#if  empolyee.role.rLevel  <   currentUser.role.rLevel >
                                <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                                <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                                <a href="/record/deletemployee.html?eId=${empolyee.eId}">删除</a>
                            <#else >
                                <#if  empolyee.eId ==  currentUser.eId >
                                    <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                                    <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                                </#if>
                            </#if>
                        </#if>

                        <#if  currentUser.role.rLevel  == 3>
                            <#if  empolyee.role.rLevel  <   currentUser.role.rLevel >
                                <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                                <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                                <a href="/record/deletemployee.html?eId=${empolyee.eId}">删除</a>
                            <#else >
                                <#if  empolyee.eId ==  currentUser.eId >
                                    <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                                    <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                                </#if>
                            </#if>
                        </#if>

                    </td>
                <#else>
                    <td>禁用</td>
                    <td></td>
                </#if>
            </tr>
        </#list>

        <tr>
            <td colspan="10">
                <a href="/record/selectemployee?eName=${eName!''}&dId=${dId}">首页</a>
                <a href="/record/selectemployee?index=${ emppage.prePage}&eName=${eName!''}&dId=${dId}"  >上一页</a>
                <a href="/record/selectemployee?index=${ emppage.nextPage}&eName=${eName!''}&dId=${dId}" >下一页</a>
                <a href="/record/selectemployee?index=${emppage.pages}&eName=${eName!''}&dId=${dId}">尾页</a>
                共${emppage.total}条 共${emppage.pageNum}/${emppage.pages}
            </td>
        </tr>
    </table>
</form>
</#if>
</body>
</html>